<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"  src="/${initParam.context_root }/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#search').click(function(){
		$.ajax({
			url : "/${initParam.context_root}/postCheck.do",
			type : "post",
			data : "dong="+$("#dong").val(),
			dataType : "json",
			success : function(jsonData){
				var str="";
				for(var i=0; i < jsonData.length; i++){
					var address = jsonData[i].sido +" "+ jsonData[i].gugun +" "+  jsonData[i].dong;
					str =str+ "<tr><td><a href=\"javascript:checkPostClose('"+jsonData[i].zipcode+"', '"+address+"')\"> "+jsonData[i].zipcode+"</a></td>";
					str = str + "<td><a href=\"javascript:checkPostClose('"+jsonData[i].zipcode+"', '"+address+"')\">"+address+"</a></td></tr>";
				}
				$("#tbody").html(str);
			}
		});
	});
});
function checkPostClose(zipcode, addressDetail){
	opener.document.registerForm.zipcode.value = zipcode;
	opener.document.registerForm.address1.value = addressDetail;
	window.close();
}
</script>
<title>우편번호찾기</title>
        <!-- 스타일 지정 -->
        <style>
            	body {font-size:12pt}   // 본문 폰트
            	th {font-size:9pt}        // 제목 폰트
            	td {font-size:9pt}        // 칸 폰트
            	a:link {color:black; text-decoration:none}        // 링크 연결된 텍스트색
            	a:visited {color:black; text-decoration:none}   // 방문했던 텍스트 색
            	a:hover {color:red; text-decoration:underline}  // 마우스 오버시 텍스트 색
            	a:active {color:red; text-decoration:none}      // 실행시 텍스트 색
        </style>
</head>
<body>
           <center>
       
       동입력 :  <input type="text" name="dong" id="dong"  style=ime-mode:active;>
                              	   <input type="submit" name="search" id="search" value="검색"><br></br>
		<fieldset> <!-- style="width:50%" -->
			<legend></legend>  <!-- 라벨 이름 -->
                <table border="1" width="100%">
                    <th width="15%">우편번호</th>
                    <th>주소</th>
                    <c:set var="zipcode_seq" scope="request" value="${requestScope.zdto.zipcode_seq }"/>
                   <tbody id="tbody"></tbody>
                </table><br>
                
                <table>
                <tr><td>&nbsp;</td></tr>
                	<tr>
     						<td colspan="2"><button onclick="window.close()">닫기</button></td>
     				</tr>
     			</table>
     			</fieldset>
            </center>
    </body>
</html>